import React, { useState, useEffect } from 'react'
import {  Outlet } from "react-router-dom"
import "./myscss/home.scss"
export default function Home() {
    const [currentTime, setCurrentTime] = useState(getCurrentTime());
    // 获取当前时间的函数
    function getCurrentTime() {
        let date = new Date();
        let hours = date.getHours();
        let minutes = date.getMinutes();
        minutes = (minutes < 10 ? '0' : '') + minutes;
        return `${hours}:${minutes}`;
    }
    // 使用 useEffect 设置定时器
    useEffect(() => {
        const intervalId = setInterval(() => {
            setCurrentTime(getCurrentTime()); // 更新当前时间
        }, 3000); // 每五秒执行一次

        // 在组件卸载时清除定时器
        return () => clearInterval(intervalId);
    }, []); // 空数组作为第二个参数，表示只在组件挂载和卸载时运行
    return (
        <div id='home1'>
            <div className='header'>
                <p>{currentTime}</p>
                <span>
                    <svg t="1721620058419" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10971" width="18" height="18"><path d="M0 704h208v192H0zM272 512h208v384H272zM544 288h208v608H544zM816 128h208v768H816z" p-id="10972" fill="#2c2c2c"></path></svg>
                    <svg t="1721619897930" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2615" width="18" height="18"><path d="M0 352.832l93.12 98.752c231.296-245.44 606.464-245.44 837.76 0L1024 352.832C741.44 53.056 283.008 53.056 0 352.832z m372.352 395.008L512 896l139.648-148.16c-76.8-81.92-202.048-81.92-279.296 0zM186.24 550.4l93.12 98.752c128.448-136.32 336.96-136.32 465.408 0L837.824 550.4c-179.648-190.592-471.488-190.592-651.648 0z" fill="#000000" p-id="2616"></path></svg>
                    <svg t="1721620142022" className="icon newdc" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12310" width="25" height="25"><path d="M167.4 374.1h620.3v275.7H167.4z" p-id="12311" fill="#2c2c2c"></path><path d="M930.1 408.6H891V305.2c0-19-15.5-34.5-34.5-34.5h-758c-18.9 0-34.5 15.5-34.5 34.5v413.5c0 18.9 15.5 34.5 34.5 34.5h758.2c18.9 0 34.5-15.5 34.5-34.5V615.4h39.1c16.5 0 29.9-13.4 29.9-29.9v-147c-0.2-16.4-13.6-29.9-30.1-29.9zM822.2 684.3H132.9V339.7h689.2v344.6z" p-id="12312" fill="#2c2c2c"></path></svg>
                </span>
            </div>
            <Outlet></Outlet>
        </div>
    )
}
